package com.zzg.srb.common.Enum;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * @Author zhengzg
 * @Date 2022/8/15 14:15
 * @Version 1.0
 */
@Getter
@AllArgsConstructor
public enum IsTrueEnum {

    /**
     * 是
     */
    YES("是",1),

    /**
     * 否
     */
    NO("否",0);

    private String name;

    private Integer value;

    /**
     * 根据枚举值获取名字
     * @param value 枚举值
     * @return 枚举name
     */
    public static String getEnumNameByValue(Boolean value){
        //定义临时变量
        Integer valueEnum = value ? 1 : 0;
        for (IsTrueEnum isTrueEnum : IsTrueEnum.values()){
            if (Objects.equals(isTrueEnum.getValue(),valueEnum)){
                return isTrueEnum.getName();
            }
        }
        return null;
    }
}
